﻿using Microsoft.AspNetCore.Authentication.Cookies;
using Microsoft.AspNetCore.Mvc;
using RuoVea.Tool.AuthorizeEx;

namespace RuoVea.Tool.Controllers
{
    public class UsersController : Controller
    {
        [Authorize]
        [Route("my")]
        public IActionResult Index()
        {
            return View();
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        [HttpGet("islogin")]
        public bool islogin()
        {
            var dd = User.Claims.Count();
            return dd > 0;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <returns></returns>
        [HttpGet("logout")]
        public IActionResult Logout()
        {
            SignOut(CookieAuthenticationDefaults.AuthenticationScheme);
            Response.Cookies.Delete("Cookies");
            return SignOut(CookieAuthenticationDefaults.AuthenticationScheme);
        }
    }
}